package com.example.demo.model;

import lombok.Data;
import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;

@Data
public class OrderInfo {
    private Integer id;
    private String orderNo;
    private Integer buyerId;
    private Integer sellerId;
    private Integer productId;
    private Double price;
    private String status;
    private String remark;
    private Date createTime;
    private Date updateTime;
    private Date paymentTime;
    private Date deliveryTime;
    private Date completionTime;
    private String expressNo;
    private Integer receivingId;
    private Integer buyerDelete;    
    private Integer sellerDelete;

    // 关联字段
    private String productName;     // 商品名称
    private String images;      // 商品图片
    private String firstImage;     // 商品第一张图片
    private String sellerNickname;  // 卖家昵称
    private String sellerAvatar;    // 卖家头像
    private String buyerNickname;   // 买家昵称
    private String buyerAvatar;     // 买家头像
    private String buyerPhone;      // 买家电话
    private String buyerAddress;    // 买家地址
    private String buyerCommentStatus; // 买家评论状态
    private String sellerCommentStatus; // 卖家评论状态
    private String buyerComment; // 买家评论
    private String sellerComment; // 卖家评论
    
    //收货地址
    private String recipientName;
    private String recipientPhone;
    private String recipientAddress;
   
    
    public void setRemark(String remark) {
        this.remark = remark;
    }
    
    public void setBuyerDelete(Integer buyerDelete) {
        this.buyerDelete = buyerDelete;
    }
    
    public void setSellerDelete(Integer sellerDelete) {
        this.sellerDelete = sellerDelete;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public void setCreateTime(String createTimeStr) {
        if (createTimeStr != null && !createTimeStr.isEmpty()) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                this.createTime = sdf.parse(createTimeStr);
            } catch (ParseException e) {
                throw new RuntimeException("日期格式错误: " + e.getMessage());
            }
        }
    }
    
    public void setPaymentTime(String paymentTimeStr) {
        if (paymentTimeStr != null && !paymentTimeStr.isEmpty()) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                this.paymentTime = sdf.parse(paymentTimeStr);
            } catch (ParseException e) {
                throw new RuntimeException("日期格式错误: " + e.getMessage());
            }
        }
    }
    
    public void setUserId(Integer userId) {
        this.buyerId = userId;  // 设置buyerId，保持兼容性
    }
    
    public Integer getUserId() {
        return this.buyerId;  // 返回buyerId，保持兼容性
    }
    
    public void setDeliveryTime(String deliveryTimeStr) {
        if (deliveryTimeStr != null && !deliveryTimeStr.isEmpty()) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                this.deliveryTime = sdf.parse(deliveryTimeStr);
            } catch (ParseException e) {
                throw new RuntimeException("日期格式错误: " + e.getMessage());
            }
        }
    }
    
    public void setCompletionTime(String completionTimeStr) {
        if (completionTimeStr != null && !completionTimeStr.isEmpty()) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                this.completionTime = sdf.parse(completionTimeStr);
            } catch (ParseException e) {
                throw new RuntimeException("日期格式错误: " + e.getMessage());
            }
        }
    }
    
    public void setUpdateTime(String updateTimeStr) {
        if (updateTimeStr != null && !updateTimeStr.isEmpty()) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                this.updateTime = sdf.parse(updateTimeStr);
            } catch (ParseException e) {
                throw new RuntimeException("日期格式错误: " + e.getMessage());
            }
        }
    }

    // 添加商品相关字段
    private Double originalPrice;
    private String description;
    private String name;
    private Integer conditionLevel;
    private Double shippingFee;
    private String brand;
    private String province;
    private String city;
    private String district;
    
    private String totalPrice;  // 添加总价字段
    

    

}
